#include <iostream>
#include <vector>
#include <algorithm>

using std::vector;
using std::cin;
using std::cout;

template <typename iter>
iter partition(iter begin, iter end, int x) {
    if(end == begin)
        return begin;
    --end;
    while (begin != end) {
        if (*begin < x) {
            ++begin;
            continue;
        }
        if (*end >= x) {
            --end;
            continue;
        }
        std::swap(*begin, *end);
    }
    return begin + (*begin < x);
}
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int x;
    cin >> x;
    int l = partition(a.begin(), a.end(), x) - a.begin();
    cout << l << std::endl << n - l;
    return 0;
}